const { Sequelize, DataTypes } = require('sequelize')
const config = require('../config/config.js')
const sequelize = new Sequelize(config)

let adminModel = sequelize.define(
  'admin',
  {
	  // 在这里定义模型属性
	  username: {
		  type: DataTypes.STRING,
		  comment: '用户名'
	  },
	  nickname: {
		  type: DataTypes.STRING,
		  comment: '昵称'
	  },
	  password: {
		  type: DataTypes.STRING,
		  comment: '密码'
	  },
	  role: {
		  type: DataTypes.INTEGER,
		  comment: '角色'
	  },
	  email: {
		  type: DataTypes.STRING,
		  comment: '邮箱'
	  },
	  phone: {
		  type: DataTypes.STRING,
		  comment: '手机号'
	  },
	  created_time: {
		  type: Sequelize.INTEGER,
		  comment: '注册时间',
		  defaultValue: Date.parse(new Date()) / 1000
	  },
	  updated_time: {
		  type: Sequelize.INTEGER,
		  comment: '更新时间',
		  defaultValue: Date.parse(new Date()) / 1000
	  }
  },
  {
	  // 这是其他模型参数
	  timestamps: false,
	  tableName: 'admin'
  }
)

module.exports = adminModel
